import {
    createRouter,
    createWebHistory,
    createWebHashHistory,
} from "vue-router";
import search from "../components/search.vue";
import index from "../components/index.vue";
import cart from "../components/cart.vue";
import person from "../components/person.vue";
import productInfo from "../components/productInfo.vue";
import collect from "../components/collect.vue";
import category from "../components/category.vue";
import categoryDetails from "../components/categoryDetails.vue";
//路由对象
`const router = createRouter({...})`
// 是一行代码，用于创建一个路由对象。这行代码使用了 `createRouter` 函数来创建一个路由对象，并将其赋值给常量 `router`。
//
// 在计算机编程中，路由是指将请求转发到适当的处理程序或资源的过程。
// 通过使用路由对象，可以将不同的URL路径映射到相应的处理程序或资源上。
// 这样，当用户访问特定的URL时，就可以根据路由规则将请求发送到正确的位置进行处理。


const router = createRouter({
    routes: [
        {
            path: "/",
            name: "admin",
            component: () => import("../components/admin.vue"),
            redirect: "/index",
            meta: {
                title: "主页",
                requireAuth: true,
            },
            children: [
                {
                    path: "/index",
                    component: index,
                    name: "index",
                },
                {
                    path: "/search",
                    component: search,
                    name: "search",
                },
                {
                    path: "/category",
                    component: category,
                    name: "category",
                },
                {
                    path: "/categoryDetails",
                    component: categoryDetails,
                    name: "categoryDetails",
                },
                {
                    path: "/cart",
                    component: cart,
                    name: "cart",
                },
                {
                    path: "/person",
                    component: person,
                    name: "person",
                },
                {
                    path: "/productInfo",
                    component: productInfo,
                    name: "productInfo",
                },
                {
                    path: "/collect",
                    component: collect,
                    name: "collect",
                },
            ],
        },
    ],
    history: createWebHashHistory(),
});
export default router;
